package com.interview01;

import java.util.Arrays;

/**
 * Copyright (C), 2018-2020
 * FileName: Demo3
 * Author:   kongfanyu
 * Date:     2020/12/4 16:53
 */
public class Demo3 {
    public static void main(String[] args) {
        int[] arr = {2,5,1,3,8,11,34};

        for (int i = 0; i < arr.length -1; i++) {
            int k = i;
            for (int j= k + 1; j < arr.length; j++){
                if (arr[j] < arr[k]){
                    k  = j;//下标
                }
            }
            if(k != i){
                int temp = arr[i];
                arr[i]  = arr[k];
                arr[k] = temp;
            }
        }
        System.out.println("排序之后:"+ Arrays.toString(arr));
    }
}
